<template>
  <div>
    <h1>地址列表</h1>
    <div>
      <el-table :data="address" style="width: 100%,height: 100%">
        <el-table-column prop="name" label="姓名" />
        <el-table-column prop="tel" label="电话" width="150" />
        <el-table-column prop="province" label="省份" width="100" />
        <el-table-column prop="city" label="城市" width="100" />
        <el-table-column prop="county" label="区" width="100" />
        <el-table-column prop="addressDetail" label="详细地址" width="180" />
        <el-table-column prop="isDefault" label="是否默认">
          <template #default="scope">
            <el-switch v-model="scope.row.isDefault" />
          </template>
        </el-table-column>
        <!-- </el-table-column>
      <el-table-column label="删除" width="180">
        <template #default="scope">
          <el-popconfirm
            title="确定要删除这条数据吗"
            @confirm="handleDelete(scope.row.bannerid)"
          >
            <template #reference>
              <el-button size="small" type="danger">删除</el-button>
            </template>
          </el-popconfirm>
        </template>
      </el-table-column> -->

        <!-- <el-table-column label="是否删除全部数据" width="180">
        <template #default="scope">
          <el-popconfirm title="确定要删除全部数据吗" @confirm="removeall()">
            <template #reference>
              <el-button size="small" type="danger">全部删除</el-button>
            </template>
          </el-popconfirm>
        </template>
      </el-table-column> -->
      </el-table>
    </div>
    
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from "vue";
import service from "../../../utils/service";
import { Delete } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";

interface iaddress {
  name: string;
  tel: number;
  city: string;
  province: string;
  county: string;
  isDefault: boolean;
  addressDetail: string;
}

let address = reactive<iaddress[]>([]);


const getaddress = () => {
  service({
    url: "/address/list",

  }).then(res => {
    if (res.data.code == "200") {
      // console.log(res.data);
      address.length = 0;
      address.push(...res.data.data);

    }
    

  });
};

// const handleDelete = (bannerid: string) => {
//   service({
//     url: "/banner/delete",
//     params: {
//       bannerid,
//     },
//   }).then((res) => {
//     if (res.data.code == 200) {
//       ElMessage({
//         message: "删除成功！",
//         type: "success",
//       });
//       getaddress();
//     }
//   });
// };
// const removeall = () => {
//   service({
//     url: "/banner/removeAll",
//   }).then((res) => {
//     if (res.data.code == 200) {
//       ElMessage({
//         message: "删除全部轮播图数据了！",
//         type: "success",
//       });
//       address();
//     }
//   });
// };

getaddress();

</script>

<style scoped>
.img {
  width: 100px;
  height: 100px;
}
</style>